Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit 72a5aac40da73e8ab757cae754a2a46ef3b6918a


Parents : 41a8692
Author : Ivan <ivan@quad4.io>
Signature : Signature validation error
Date : 2026-04-13T18:28:08-05:00

feat(identity_context): implement receive completed handler for RNCP and enhance teardown process for receive destination

Changes

1 files changed, 18 insertions(+), 0 deletions(-)


Diff

diff --git a/meshchatx/src/backend/identity_context.py b/meshchatx/src/backend/identity_context.py
index 4a78bc4b..c4dccfa3 100644
--- a/meshchatx/src/backend/identity_context.py
+++ b/meshchatx/src/backend/identity_context.py
@@ -93,6 +93,18 @@ class IdentityContext:
self.running = False
+ def _rncp_emit_receive_completed(self, payload):
+ try:
+ from meshchatx.src.backend.async_utils import AsyncUtils
+
+ AsyncUtils.run_async(
+ self.app._broadcast_websocket_message(
+ {"type": "rncp.receive.completed", **payload},
+ ),
+ )
+ except Exception:
+ pass
+
def setup(self):
print(f"Setting up Identity Context for {self.identity_hash}...")
@@ -235,6 +247,7 @@ class IdentityContext:
identity=self.identity,
storage_dir=self.app.storage_dir,
)
+ self.rncp_handler.on_receive_completed = self._rncp_emit_receive_completed
self.rnstatus_handler = RNStatusHandler(
reticulum_instance=getattr(self.app, "reticulum", None),
)
@@ -479,6 +492,11 @@ class IdentityContext:
# 2. Cleanup RNS destinations and links
try:
+ if self.rncp_handler:
+ with contextlib.suppress(Exception):
+ self.rncp_handler.teardown_receive_destination()
+ self.rncp_handler = None
+
if self.message_router:
# Break cycles in mocks/objects
if hasattr(self.message_router, "register_delivery_callback"):


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────